UpstreamHook.remove('pyrinoc_up')
UpstreamHook.add('pyrinoc_up', Proc.new {|cs|
  if cs =~ /^q (.+)$/
    echo run_query($1)
  elsif cs == "gq"
    start_proc(Proc.new {
      go2('quest')
      put('quest request', 'quest info')
    })
    nil
  elsif cs == "qc"
    start_proc(Proc.new {
      go2('quest')
      put('quest complete')
    })
    nil
  elsif cs == "hot"
    start_proc(Proc.new {go2(26151)})
    nil
  elsif cs =~ /^runto .+$/
    if Room.current.db_id != Map.get_mapping('recall')
      start_proc(Proc.new {
        go2('recall')
        put(cs)
      })
      nil
    else
      cs
    end
  elsif cs =~ /wh (.+)$/
    start_proc(Proc.new {
      targ_info = $1.split('.')
      targ_info.length == 2 ? where(targ_info[1], targ_info[0].to_i) : where(targ_info[0])
    })
    nil
  elsif cs =~ /^(\d+)$/
    hunt_cp("HUNT-#{$1}")
    nil
  else
    cs
  end
})

KeyHook.remove('key_handler')
KeyHook.add('key_handler', Proc.new {|e, m|
  moves = {104=>'n', 102=>'e', 98=>'s', 100=>'w', 105=>'u', 103=>'d'}
  if moves.key?(e.keycode)
    start_script('mv', moves[e.keycode])
    false
  else
    true
  end
})